package com.qiaoxg.greendaodemo;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.widget.TextView;

import com.qiaoxg.greendaodemo.Entity.DaoMaster;
import com.qiaoxg.greendaodemo.Entity.DaoSession;
import com.qiaoxg.greendaodemo.Entity.UserBean;
import com.qiaoxg.greendaodemo.Entity.UserBeanDao;

import java.util.UUID;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    mTextMessage.setText(R.string.title_home);

                    UserBean userBean1 =new UserBean();
                    userBean1.setName("zjq1");
                    String uuid1 = UUID.randomUUID().toString();
                    userBean1.setUuid(uuid1);
                    DBManager.getInstance(MainActivity.this).insertUser(userBean1);
                    return true;
                case R.id.navigation_dashboard:
                    mTextMessage.setText(R.string.title_dashboard);

                    UserBean userBean2 =new UserBean();
                    String uuid2 = UUID.randomUUID().toString();
                    userBean2.setUuid(uuid2);
                    userBean2.setName("zjq2");
                    DBManager.getInstance(MainActivity.this).insertUser(userBean2);                    return true;
                case R.id.navigation_notifications:
                    mTextMessage.setText(R.string.title_notifications);

                    UserBean userBean3 =new UserBean();
                    String uuid3 = UUID.randomUUID().toString();
                    userBean3.setUuid(uuid3);
                    userBean3.setName("zjq3");
                    DBManager.getInstance(MainActivity.this).insertUser(userBean3);                    return true;
            }
            return false;
        }

    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mTextMessage = (TextView) findViewById(R.id.message);
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

        UserBean userBean =new UserBean();
        userBean.setName("zjq");
        DBManager.getInstance(MainActivity.this).insertUser(userBean);

    }
}
